#include <string>
#include <iostream>
#include <sstream>
using namespace std;

//class declaration
class Time
{
    int hour = 0;
    int minute = 0;
    int second = 0;
public:
    Time();
    Time(int h, int m, int s);

    //getter and setter
    int getHour();
    int getMinute();
    int getSecond();
    void setHour(int h);
    void setMinute(int m);
    void setSecond(int s);
    //display
    string toString24();
    string toString12();
};

Time::Time()
{
    hour = minute = second = 0;
}

Time::Time(int h, int m, int s)
{
    if(h >= 0 && h < 24)
        hour = h;
    if(m >= 0 && m < 60)
        minute = m;
    if(s >= 0 && s < 60)
        second = s;
}

int Time::getHour()
{
    return hour;
}

int Time::getMinute()
{
    return minute;
}

int Time::getSecond()
{
    return second;
}

void Time::setHour(int h)
{
    if(h >= 0 && h < 24)
        hour = h;
}

void Time::setMinute(int m)
{
    if(m >= 0 && m < 60)
        minute = m;
}

void Time::setSecond(int s)
{
    if(s >= 0 && s < 60)
        second = s;
}

string Time::toString24()
{
    ostringstream os;
    os << hour << ":" << minute << ":" << second;
    return os.str();
}

string Time::toString12()
{
    ostringstream os;

    if(hour > 0 && hour < 12)
        os << hour << ":" << minute << ":" << second << " A.M.";
    else if(hour == 0)
        os << (hour + 12) << ":" << minute << ":" << second << " A.M.";
    else if(hour == 12)
        os << hour << ":" << minute << ":" << second << " P.M.";
    else
        os << (hour - 12) << ":" << minute << ":" << second << " P.M.";

    return os.str();
}

int main()
{
    Time t1(23, 15, 35);
    Time t2(12, 35, 7);
    Time t3(0, 23, 19);
    Time t4;

    cout << t1.toString12() << "\t" << t1.toString24() << endl;
    cout << t2.toString12() << "\t" << t2.toString24() << endl;
    cout << t3.toString12() << "\t" << t3.toString24() << endl;
    cout << t4.toString12() << "\t" << t4.toString24() << endl;

    return 0;
}




